<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>图片</title>
<link rel="stylesheet" type="text/css" href="control.css"/>
<link rel="stylesheet" type="text/css" href="control_main.css" />
<script type="text/javascript">
var pg=null;
window.onload = function(){
	var url = "/networkforum/control/picture_group_control.do";
	
	var myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get(url,function(d){
		pg = toJson(d);
		//page.view('articleInner',article,articleOption);
		//page.view("rightUlInner",data,pictureOption);
	});
	myajax = null;

	searchInfo();
}
function searchInfo(){
	clearUlInner();
	var userName = document.getElementById("un").value;
	var pictureType = document.getElementById("pt").value;
	var uploadTime = document.getElementById("control_date").value;
	var url = "/networkforum/control/picture_control.do?pictureOwner="+userName+
		"&uploadTime="+uploadTime+"&pictureType="+pictureType;
	
	var myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get(url+"&index=0&size=100",function(d){
		var data = toJson(d);
		page.view("rightUlInner",data.slice(0,4),pictureOption);
		window.parent.iFrameHeight();
		paging.page({
			size:4,
			total:Math.ceil(data.length/4),
			data:data,
			ajaxLoad:false,
			previou:document.getElementById("previouPage"),
			next:document.getElementById("nextPage"),
			current:document.getElementById("currentPage"),
			max:document.getElementById("totalPage"),
			callBack:function(d){
				clearUlInner();
				page.view("rightUlInner",d,pictureOption);
			},
		});
	});
	myajax = null;
}
var pictureOption = {
	userName:{
		param:{id:"userName"},
		bind:{pictureId:"pictureId"},
		style:{color:"blue"}
	},
	pictureAddress:{
		param:{id:"picture"}
	},
	uploadTime:{
		param:{id:"uploadTime"}		
	},
	reviewTimes:{
		param:{id:"replyTimes"}
	},
	pictureGroupName:{
		param:{id:"pictureGroupName"}
	}
}
function pictureHandle(event){
	event = event || window.event;
	var target = event.target || event.srcElement;
	var hs = document.getElementById("handleSelect");
	if(!hs){
		hs = document.getElementById("handle").cloneNode(true);
		hs.id = "handleSelect";
	}
	target.parentElement.appendChild(hs);
	var option = {
			'pictureGroupName':{
				'param':{'id':"typeName"},
				bind:{pictureGroupId:"pictureGroupId"}
			}
		};
	var param = {
			//'data':[{'name':"美女"},{'name':"性感"}],
			'data':pg,
			'target':target,
		};
	page.combo("handleSelect",param,option);
}
function save(){
	var items = document.getElementsByClassName("checkBox");
	
	var len = items.length;
	var pictureIds = new Array();
	var gn = new Array();
	for(var i =0;i<len ;i++){
		var ite = items[i];
		if(ite.checked){
			var li = ite.parentElement;
			var pictureId = li.children[1].pictureId;
			var name = li.children[li.children.length-2].value;
			//arr.push({userId:userId,roleName:roleName});
			pictureIds.push(pictureId);
			gn.push(encodeURIComponent(name));
		}
	}
	if(pictureIds.length==0){
		return;
	}
	var url = "/networkforum/control/picture_control_change.do";
	var myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get(url+"?pictureIds="+pictureIds+"&groupNames="+gn,function(d){
		location.reload();
	});
	myajax = null;
}
</script>
</head>

<body>
    <div id="rightNav">
        <ul class="rightUl">
            <li>
                <span>用户</span>
                <input id="un" type="text"/>
            </li>
            <li>
                <span>类型</span>
                <input id="pt" type="text"/>
            </li>
            <li>
                <span>上传时间时间</span>
                 <input name="control_date" id="control_date" type="text" value="" readonly="true" onclick="new Calendar().show(this);" />
            </li>
        </ul>
        <span id="search" onClick="searchInfo();">搜索</span>
    </div>
    <div id="userCenter" class="rightCenter">
        <ul id="rightUlInner" class="rightUlInner">
            <li style="display:none;">
                <input class="checkBox" type="checkbox" style="width:5%;margin-right:4px;"/>
                <span id="userName" style="width:10%;text-align:left;"></span>
                <div style="width:20%;display: inline-block;text-align: left;">
	                <img id="picture" style="width:100px;height:80px;"></span>
                </div>
                <span id="uploadTime" style="width:15%;text-align:left;"></span>
                <span id="replyTimes" style="width:10%;text-align: center;"></span>
                <span id="pictureGroupName" style="width:10%;text-align: left;"></span>
                <input type="text" onclick="pictureHandle(event);" readonly style="width:55px;margin-left:50px;"/>
            </li>
            <li id="header">
                <span style="width:5%;">全部</span>
                <span style="width:10%;text-align:left;">用户</span>
                <span style="width:20%;">图片</span>
                <span style="width:15%;text-align:left;">上传时间</span>
                <span style="width:10%;text-align: center;">评论次数</span>
                <span style="width:10%;text-align: left;">类型</span>                
                <span style="width:10%;text-align:right;">管理</span>
            </li>
        </ul>
        <div class="paging" id="paging">
	   		<div class="clear"></div>
	   		<span id="previouPage" style="cursor: pointer;">上一页</span>
	   		<!--  <span id="currentPage2">1</span>-->
	   		<input id="currentPage" type="text" value = "1"/>	
	   		<span id="nextPage" style="cursor: pointer;">下一页</span>
	   		<span id="totalPage">共 1 页</span>
	   	</div>
        <span id="saveButtom" onclick="save();">保存</span>
        <ul id="handle" style="display:none;">
            <li>
           		<span id="typeName"></span>
        	</li>
        </ul>
     </div>
</body>
<script type="text/javascript" src="control_main.js"></script>
<script src="../js/view.js" type="text/javascript"></script>
<script src="../js/combo.js" type="text/javascript"></script>
<script src="../js/myajax.js" type="text/javascript"></script>
<script src="../js/pageing.js" type="text/javascript"></script>

<script type="text/javascript" src="/networkforum/js/Calendar3.js"></script>
</html>
